﻿using LxBasic;

namespace LxCore
{
    public partial class JointCFDFields : JsObject
    {
        public JointCFDFields(FvJoint cont)
        {
            this.Joint = cont;
        }
        public FvJoint Joint;
        public JointCond JointCond;
        ZoneCond OZoneCond;
        ZoneCond NZoneCond;
        public void CheckCreate()
        {
            JointCond = ResHelper.GetCond(Joint);
            OZoneCond = ResHelper.GetCond(Joint.OZone);
            NZoneCond = ResHelper.GetCond(Joint.NZone);
            if (!JointCond.IsEnabled)
                return;
            SetParameter_T();
        }
    }
    public partial class JointCFDFields
    {
        public  EquationConnectBase Temperature;

        public void SetParameter_T()
        {
            switch (OZoneCond.PhysicalModel.IsEnergyEnabled, NZoneCond.PhysicalModel.IsEnergyEnabled)
            {
                case (true, true):
                    if (JointCond.ThermalResistance.IsEqual0())
                    {
                        CheckCreator.Instance(ref Temperature, out ConnectWallOneSide Ttemp);
                        Ttemp.CheckCreate(Joint);
                        Ttemp.SetConnect(ResHelper.GetField(Joint.OZone).Temperature, ResHelper.GetField(Joint.NZone).Temperature, JointCond.EnergySource_b, JointCond.EnergySource_a);// Joint.OZone.CFDFields.T, Joint.NZone.CFDFields.T, Joint.CFDSetting.EnergySource_b, Joint.CFDSetting.EnergySource_a) ;
                        //LxSim.Sim.Solvers.TemperatureGroup.ConnectsStorage.Add(Ttemp);
                    }
                    else
                    {
                        CheckCreator.Instance(ref Temperature, out ConnectWallTwoSide Ttemp);
                        Ttemp.CheckCreate(Joint);
                        Ttemp.SetConnect(ResHelper.GetField(Joint.OZone).Temperature, ResHelper.GetField(Joint.NZone).Temperature, JointCond.EnergySource_b, JointCond.EnergySource_a, JointCond.ThermalResistance);
                        //LxSim.Sim.Solvers.TemperatureGroup.ConnectsStorage.Add(Ttemp);
                    }
                    break;
                case (true, false):
                case (false, true):
                    throw new Exception("边界一侧未启用能量方程");
                case (false, false):
                    Temperature = null;
                    break;
            }


        }
    }
}

//int flag = 0;
//flag += Convert.ToInt32(Joint.OZone.CFDSetting.PhysicalModel.IsEnergyEnabled);
//flag += Convert.ToInt32(Joint.NZone.CFDSetting.PhysicalModel.IsEnergyEnabled);
//if (flag == 0)
//{

//}
//else if (flag == 1)
//{

//}
//else
//{

//}